<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>新增代理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,address=no"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" type="text/css" href="../css/mobiscroll.jquery.min.css"/>
    <link rel="stylesheet" href="../css/common.css"/>
    <link rel="stylesheet" href="../css/main.css"/>
</head>
<body class="ad_add">
    <article class="bigBox">
        <section class="container">
            <div class="flex_sb h100 plr24 bw bdb">
                <span>代理类型</span>
                <div class="flex_a">
                    <label class="flex_a shi">
                        <input type="radio" name="type" hidden class="anchor" value="2">
                        <span class="anchor_ico"></span>
                        <cite class="ml10">市代理</cite>
                    </label>
                    <label class="flex_a ml40 qu">
                        <input type="radio" name="type" hidden class="anchor" value="3">
                        <span class="anchor_ico"></span>
                        <cite class="ml10">区代理</cite>
                    </label>
                    <label class="flex_a ml40 personal">
                        <input type="radio" name="type" hidden class="anchor" value="4">
                        <span class="anchor_ico"></span>
                        <cite class="ml10">个人代理</cite>
                    </label>
                </div>
            </div>
            <label class="flex_sb bw plr24 h100 bdb" id="city">
                <span>投放城市</span>
                <div class="arrow_right flex_a ml20">
                    <input type="text" placeholder="请选择" class="mr20 tae city" name="city" readonly>
                    <img src="../img/arrow_right.png"/>
                </div>
            </label>
            <label class="flex_a h100 bdb plr24 bw">
                <span>代理名称</span>
                <input type="text" placeholder="请输入" class="tae ml20 flex1" name="name">
            </label>
            <label class="flex_a h100 bdb plr24 bw">
                <span>手机号</span>
                <input type="number" placeholder="请输入" class="tae ml20 flex1" name="phone">
            </label>
            <label class="flex_a h100 bdb plr24 bw">
                <span>密码</span>
                <input type="password" placeholder="请输入" class="tae ml20 flex1" name="pass">
            </label>
            <label class="flex_a h100 bdb plr24 bw">
                <span>重复密码</span>
                <input type="password" placeholder="请输入" class="tae ml20 flex1" name="passa">
            </label>
            <div class="flex_sb h100 plr24 bw bdb">
                <span>账号状态</span>
                <div class="flex_a">
                    <label class="flex_a">
                        <input type="radio" name="type1" hidden class="anchor" value="1">
                        <span class="anchor_ico"></span>
                        <cite class="ml10">启用</cite>
                    </label>
                    <label class="flex_a ml40">
                        <input type="radio" name="type1" hidden class="anchor" value="2">
                        <span class="anchor_ico"></span>
                        <cite class="ml10">禁用</cite>
                    </label>
                </div>
            </div>
            <p class="col9 fw pl30 ptb30">佣金设置</p>
            <div class="flex_sb h100 plr24 bw bdb">
                <span>选择类型</span>
                <div class="flex_a">
                    <label class="flex_a">
                        <input type="radio" name="type2" hidden class="anchor" value="1" checked>
                        <span class="anchor_ico"></span>
                        <cite class="ml10">按比例</cite>
                    </label>
                    <label class="flex_a ml40">
                        <input type="radio" name="type2" hidden class="anchor" value="2">
                        <span class="anchor_ico"></span>
                        <cite class="ml10">按金额</cite>
                    </label>
                </div>
            </div>
            <label class="flex_a h100 bdb plr24 bw">
                <span class="leixing">金额</span>
                <input type="text" placeholder="请输入" class="tae ml20 flex1" name="money" id="mon">
            </label>
        </section>
        <footer class="ptb20 pw100">
            <div class="plr30">
                <button class="border-r6 bgc1 colw tac lh90 pw100 btn_tap font16">添加</button>
            </div>
        </footer>
    </article>
</body>
</html>
<script src="../js/jquery.min.js"></script>
<script src="../js/mobiscroll.jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery.form.js"></script>
<script src="../js/dlc.js"></script>
<script>

    if(get_save('role')==2){
        $('.shi').hide();
    }else if(get_save('role')==3){
        $('.shi').hide();
        $('.qu').hide();
    }
    $('#mon').on('input',function () {
        if($('input[name=type2]:checked').val()==1){
            $('#mon').val($(this).val().replace(/^0|\D/g,''));
        }
    });
    //佣金类型
    $('input[name=type2]').change(function(){
        if($('input[name=type2]:checked').val()==1){
            $('.leixing').text('比例');
        }else{
            $('.leixing').text('金额');
            $('input[name=money]').attr('oninput',"")
        }
        });

    var city = ['东莞','深圳','广州'];
    //选择代理人
    $('#city').mobiscroll().scroller({
        theme: 'ios',
        wheels:[
            [{
                data:['东莞', '深圳', '广州', '佛山', '珠海', '揭阳', '惠州', '汕头']
            }]
        ],
        display: 'bottom',
        headerText:'选择城市',
        lang: 'zh',
        onBeforeClose: function (event, inst) {
            if (event.button == 'set') {
                $('.city').val(event.valueText);
            }
        }

    });

    $('.btn_tap').click(function(){
        var type = $('input[name=type]:checked').val();
        var pass = $('input[name=pass]').val();
        var passa = $('input[name=passa]').val();
        var city = $('input[name=city]').val();
        var name = $('input[name=name]').val();
        var status = $('input[name=type1]:checked').val();
        var type2 = $('input[name=type2]:checked').val();
        var money = $('input[name=money]').val();
        var phone = $('input[name=phone]').val();
        if(isNull(type)){
            dlctipbox.show('请选择代理类型');
        }else if(isNull(city)){
            dlctipbox.show('请选择投放城市');
        }else if(isNull(name)){
            dlctipbox.show('请输入名称');
        }else if(isNull(phone)){
            dlctipbox.show('请输入手机号码');
        }else if(!checkMobileAndTel(phone)){
            dlctipbox.show('手机号码格式不正确')
        }
        else if(isNull(pass)){
            dlctipbox.show('请输入密码');
        }else if(isNull(passa)) {
            dlctipbox.show('请再次输入密码');
        }else if(pass!=passa){
            dlctipbox.show('两次输入的密码不一致');
        }
        else if(isNull(status)) {
            dlctipbox.show('请选择账号状态');
        }else if(isNull(type2)){
            dlctipbox.show('请选择佣金类型');
        }else if(isNull(money)){
            dlctipbox.show('请输入金额');
        }
        else{
            var data = {
                'role':type,
                'city':city,
                'name':name,
                'phone':phone,
                'password':pass,
                'rePassword':passa,
                'status':status,
                'commissionType':type2,
                'commissionValueFloat':money
            };
            console.log(data);
            dlc_request('/api/agent/saveAgent',data,function(res){
               console.log(res);
                if(res.code == 1){
                    dlctipbox.show('提交成功');
                    setTimeout(function(){
                        history.go(-1);
                    },2000);
                }else{
                    dlctipbox.show(res.msg);
                }
            });
        }
    });
</script>






















